package queue;

public class ArrayQuenu<T> implements MyQueue<T> {
    private int MaxSize = 10;
    private Object[] arr = new Object[MaxSize];
    private int front = 0;
    private int rear = 0;

    public ArrayQuenu() {
    }

    public ArrayQuenu(int maxSize) {
        MaxSize = maxSize;
        arr = new Object[maxSize];
    }

    @Override
    public boolean isEmpty() {
        return rear == front ? true : false;
    }

    @Override
    public boolean add(T x) {
        if (isFull()) {
            throw new RuntimeException("队列已经满");
        }

        return true;
    }

    @Override
    public T poll() {
        if (isFull()){
            return null;
        }
        T var=(T) arr[front];
        arr[front]=null;
        front=(front+1)%MaxSize;
        return null;
    }

    @Override
    public T peek() {
        return null;
    }

    private boolean isFull() {
        return false;
    }
}
